Skip to content

Port #[custom_mir(..)] to the new attribute system #145206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scrabsha
Copy link
Contributor

@rustbot
Copy link
Collaborator

rustbot commented Aug 10, 2025

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 10, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@rust-log-analyzer

This comment has been minimized.

let (dialect, span) = dialect?;

let dialect = match dialect.as_str() {
"analysis" => MirDialect::Analysis,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can match directly on symbols here, so sym::analysis


let phase = match phase.as_str().to_ascii_lowercase().as_str() {
"initial" => MirPhase::Initial,
"post_cleanup" | "post-cleanup" | "postcleanup" => MirPhase::PostCleanup,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the original impl have 3 variants? This feels like something that should be specified and then changed to one of these 3


#[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)]
#[derive(HashStable_Generic, PrintAttribute)]

Copy link
Contributor Author

@scrabsha scrabsha Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did i end up inserting a newline here?!

return;
};

let string_of_dialect = || match dialect {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could implement a trait that allows these to be used in diagnostics directly. I forgot which, maybe IntoDiagnosticsValue? Something like that. It's from rustc_errors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherent method name is usually a simple enough way to do that.

}
}
}

impl RuntimePhase {
pub fn parse(phase: Option<String>) -> Self {
pub fn parse(phase: Option<attrs::MirPhase>) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this method be inlined into its use sites now that it's so simple? Like the other *Phase::parse?

return;
};

let string_of_dialect = || match dialect {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherent method name is usually a simple enough way to do that.

@jdonszelmann
Copy link
Contributor

@cjgillot yea I told sasha off-github the same yesterday. Let's just collapse all those alternate syntaxes into one and make them symbols. :)

@scrabsha
Copy link
Contributor Author

(i'm kinda busy trying to unbreak the tests, i'll go through all these discussions once i have something that works (i was convinced i ran the tests before opening the PR, but apparently no --'))

@scrabsha scrabsha force-pushed the push-uxovoqzrxnlx branch 3 times, most recently from 22677db to 4acaec2 Compare August 11, 2025 19:58
@scrabsha
Copy link
Contributor Author

@cjgillot @jdonszelmann I think I addressed everything you raised in this PR :)

@rust-log-analyzer

This comment has been minimized.

@jdonszelmann
Copy link
Contributor

awesome, looks good! @bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 12, 2025

📌 Commit e854013 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2025
Kobzol added a commit to Kobzol/rust that referenced this pull request Aug 12, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? `@jdonszelmann`
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 12, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ``@jdonszelmann``
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 12, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ```@jdonszelmann```
@jhpratt
Copy link
Member

jhpratt commented Aug 12, 2025

@bors r-

#145317 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 12, 2025
@scrabsha
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 12, 2025
@jdonszelmann
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 12, 2025

📌 Commit 17d11f6 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 13, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? `@jdonszelmann`
@jdonszelmann
Copy link
Contributor

@bors r-

will conflict with #145085

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 13, 2025
@jdonszelmann jdonszelmann added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 14, 2025
@jdonszelmann
Copy link
Contributor

@bors r+ (the other one has had some delays)

@bors
Copy link
Collaborator

bors commented Aug 14, 2025

📌 Commit a42cc37 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 14, 2025
@jdonszelmann
Copy link
Contributor

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 14, 2025
@scrabsha
Copy link
Contributor Author

Apparently #145085 is ready - I'll rebase this PR once it is merged :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants